<?php

namespace App\Module\Api\Controllers;
use App\Module\Api\Controllers\Request\RegionListRequest;
use App\Module\Api\Validator\CategoryListValidator;
use App\System\Base\Repositories\BaseRegionRepository;

/**
 * 分类列表
 * @package App\Module\Admin\Controllers
 */
class RegionListController extends Controller
{
    public function __construct()
    {
        $this->query= new RegionListRequest();
        parent::__construct();
    }
    //主页
    public function index()
    {
        (new CategoryListValidator())->check();

        $action = $this->query->action;
        $user = BaseRegionRepository::getInstance();
        $data = '';

        if($action == 1)
        {//省市区列表
            $data = $user->getList($this->table);
            return apiResponse($data);
        }else{
            $id = $this->query->id;
            $data = $user->getOne($id);
            return apiResponse($data);
        }


    }

}
